import java.io.*;
import java.util.HashMap;

public class ColumnWidth
{
	static HashMap<String, Integer> widthMap;

	static
	{
		File widthFile = new File(gqqnbig.SystemHelper.getExecutablePath(), "width.data");
		try
		{
			ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(widthFile));

			widthMap = (HashMap<String, Integer>) inputStream.readObject();

			inputStream.close();

		}
		catch (Exception e)
		{
			widthMap = new HashMap<String, Integer>();
		}
	}

	public static void setWidth(String name, int width)
	{
		widthMap.put(name, width);
	}

	public static int getWidth(String name)
	{
		if (widthMap.containsKey(name) == false)
			widthMap.put(name, 75);

		return widthMap.get(name);
	}

	public static void write() throws IOException
	{
		File widthFile = new File(gqqnbig.SystemHelper.getExecutablePath(), "width.data");
		ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(widthFile));
		outputStream.writeObject(widthMap);
		outputStream.close();
	}

}
